import {useUserStore} from "~/stores/user-store";

/**
 * 自定义权限按钮
 */
export default defineNuxtPlugin((nuxtApp) => {
    const userStore = useUserStore();
    const permissions = userStore.getAuthorities;
    const  show=(el:any,binding:any)=>{
        if (!permissions) {
            el.remove();
        }
        if (!permissions.includes(binding.value)) {
            el.remove();
        }
    }
    nuxtApp.vueApp.directive('auth', {
        beforeMount(el, binding) {
            show(el,binding);
        },
        mounted(el, binding) {
            show(el,binding);
        },
        beforeUpdate(el, binding) {
            show(el,binding);
        },
        updated(el, binding) {
            show(el,binding);
        }
    })
})
